package com.cyw.note.common;

import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
public class RespBean1 {
    private Integer code = 0;
    private String msg;
    private Object data;
    /**
     * 成功
     */
    public static final int SUCCESS = 200;

    /**
     * 失败
     */
    public static final int FAIL = 500;

    public static RespBean1 build(){
       return new RespBean1();
    }
    public static RespBean1 success(String msg){
        return new RespBean1(SUCCESS,msg,null);
    }
    public static RespBean1 success(Object data){
        return new RespBean1(SUCCESS,"成功",data);
    }

    public static RespBean1 success(){
        return new RespBean1(SUCCESS,"操作成功",null);
    }

    public static RespBean1 success(String msg, Object data){
        return new RespBean1(SUCCESS,msg,data);
    }

    public static RespBean1 error(String msg){
        return new RespBean1(FAIL,msg,null);
    }

    public static RespBean1 error(){
        return new RespBean1(FAIL,"操作失败",null);
    }

    public static RespBean1 error(String msg, Object data){
        return new RespBean1(FAIL,msg,data);
    }

    private RespBean1(Integer code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

}

